<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    var interpret = function (command) {
      let res = '';
      for (let i = 0; i < command.length; i++) {
        if (command[i] === 'G') {
          res += 'G';
        } else if (command[i] === '(') {
          if (command[i + 1] === ')') {
            res += 'o';
          } else {
            res += 'al';
          }
        }
      }
      return res;
    };
    console.log(interpret("G()(al)"));
  </script>
</body>

</html>